<?php

class fbTemplate {
	private $eng;
	private $template;
	private $children;
	
	function __construct($template) {
		$this->eng = new bTemplate();
		$this->template = $template;
		$this->children = array();
	}
	
	function set($key, $val) {
		$this->eng->set($key, $val);
	}
	
	function setif($key, $val) {
		$this->eng->set($key, $val, TRUE);
	}
	
	function set_cloop($key, $data, $cases) {
		$this->eng->set_cloop($key, $data, $cases);
	}

	function add_child($key, $eng) {
		$this->children[$key] = $eng;
	}
	
	function render() {
		if(count($this->children) > 0) {
			foreach($this->children as $key => $eng) {
				$this->set($key, $eng->render());
			}
		}
		return $this->eng->fetch($this->template);
	}
}


?>